//
//  deleUserNumberViewController.m
//  dongfengTest
//
//  Created by wxt on 2021/3/18.
//

#import "LoginOutUserNumberViewController.h"
#import "HomeViewController.h"

@interface LoginOutUserNumberViewController ()

@end

@implementation LoginOutUserNumberViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = Wcolor;
    self.navigationItem.title= @"账号注销";
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];

    UIButton * backBtn = [UIButton createBtnFrame:CGRectMake(0, 0, 18, 18) title:@"" bgImageName:@"fanhui" action:^(UIButton *button) {
        [self.navigationController popViewControllerAnimated:YES];
    }];
    UIBarButtonItem * blachItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = blachItem;
    
    
    [self addUIView];
    
    
    // Do any additional setup after loading the view.
}
-(void)addUIView{
    
    
    tklImgView * signImg = [tklImgView imgViewWithFrame:CGRectMake(kTopHeight+80, kWidth/2-50, 100, 100) img:@"tishi1"];
    [self.view addSubview:signImg];
    
    TKLlable * signLab = [TKLlable labelWithFrame:CGRectMake(30, CGRectGetMaxY(signImg.frame)+10, kWidth-60, 60) text:@"退出当前登录账号" textColor:[UIColor grayColor] font:Font_6(14) textAlignment:Textcenter backgroundColor:Ccolor];
    signLab.numberOfLines = 3;
    [self.view addSubview:signLab];
    
    
    
    UIButton * deleBtn = [UIButton createBtnFrame:CGRectMake(20, CGRectGetMaxY(signLab.frame)+50, kWidth-40, 40) title:@"退出登录" bgImageName:@"" action:^(UIButton *button) {
        
        //
        
        [self cancellationUserName];

        

    }];
    deleBtn.backgroundColor = JhColor(204, 204, 204);
    deleBtn.layer.masksToBounds = YES;
    deleBtn.layer.cornerRadius = 20;
    [self.view addSubview:deleBtn];
    
}


-(void)cancellationUserName{
    
    
    [AFNetworkUtils DELETE:kUser_LoginOut_Api body:nil success:^(NSDictionary * _Nonnull responseObject) {
           NSLog(@"%@",responseObject) ;
        if ([responseObject[@"code"] intValue] == 200) {
            //成功
            UIViewController *rootVC = self.presentingViewController;
            while(rootVC.presentingViewController) {
            rootVC= rootVC.presentingViewController;
            }
            
         [rootVC dismissViewControllerAnimated:YES completion:nil];
            
        }
        
        
        } failure:^(NSString * _Nonnull error) {
            ;
        }];
    
    
    
    
  
    
    
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
